<!--
 * @FilePath     : /study_code/jquery/plugin-jquery-tmpl-from-origindata.html
 * @Description  : jquery.tmpl 使用远程数据使用插件
 * @Date         : 2025-04-21 13:40:38
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-21 13:45:05
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
  </head>
  <body>
    <table cellspacing="0" cellpadding="3" border="1">
      <tbody id="rows"></tbody>
    </table>

    <script id="myTemplate" type="text/x-jquery-tmpl">
      <tr>
        <td>${id}</td>
        <td>${name}</td>
      </tr>
    </script>

    <script src="/jquery/dist/jquery.min.js"></script>
    <script src="/jquery/plugins/jquery.tmpl/lib/jquery.tmpl.min.js"></script>
    <script src="/jquery/ajax/common.js"></script>

    <script>
      $(function () {
        $.ajax({
          url: baseUrl.root + baseUrl.ajax + '/jq-tmpl',
          type: 'GET',
          success: function (res) {
            console.log(1, '返回的数据')
            if (res.code == 200) {
              $('#myTemplate').tmpl(res.data).appendTo('#rows')
            }
          },
          error: function (err) {
            console.log(2, '请求失败', err)
          },
        })
      })
    </script>
  </body>
</html>
